
import java.util.*;

public class Practice4_3 {
	enum suit{
		spades, hearts, diamonds, clubs
	}
	enum rank{
		A("ace"), NUM1("1"), NUM2("2"), NUM3("3"), NUM4("4"), NUM5("5"), NUM6("6"), 
		    NUM7("7"), NUM8("8"), NUM9("9"), NUM10("10"), J("jack"), Q("queen"), K("king");
		private String name ;
		private rank(String name){
	        this.name = name ;
	    }
		public String toValue() {
			return name;
		}
	}
	public static void main(String[] args) {
		int numHands = Integer.parseInt(args[0]);
		int cardsPerHand = Integer.parseInt(args[1]);
		
		List<String> deck = new ArrayList <String>();
		for(suit es: suit.values())
			for(rank er: rank.values())
				deck.add(er.toValue() + " of " + es);
		Collections.shuffle(deck);
		for(int i = 0; i < numHands; i++)
			System.out.println(dealHand(deck, cardsPerHand));
	}
	public static List<String> dealHand(List<String> deck, int n) {
		int deckSize = deck.size();
		List<String> handView = deck.subList(deckSize - n, deckSize);
		List<String> hand = new ArrayList<String>(handView);
		handView.clear();
		return hand;
	}
}
